#ifndef CPIR_MESSAGE_H
#define CPIR_MESSAGE_H

#include "common.h"
#include "socket.h"
#include "time.h"
#include "stdio.h"
#include <iostream>
#include <fstream>

//   Copyright 2011 CPIR Team
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.

//CipherMessage
class CipherMessage : public ISerializable 
{
	int32_t raw;  
public:
	CipherMessage(int32_t raw) : raw(raw) {}
	~CipherMessage();
	int32_t getRaw() const;
	const Serialization getSerialization() const;
	static CipherMessage* fromRaw(Serialization s);		
};

//Message
class Message : public ISerializable 
{
	int32_t raw;
public:
	Message(int32_t raw) : raw(raw) {}
	~Message();
	int32_t getData() const;
	const Serialization getSerialization() const;
	static Message* fromRandom();
	static Message* fromString(char* str);
	static Message* fromRaw(Serialization s);
};

//MessageCollection
class MessageCollection : public ISerializable
{
	uint32_t size;
	int32_t *raw;
public:
	MessageCollection( uint32_t );
	MessageCollection( uint32_t, int32_t* );
	~MessageCollection();
	const Message* get(const uint32_t n) const;
	void set(const uint32_t n, const Message* msg);
	uint32_t getSize() const;
	const Serialization getSerialization() const;
	static MessageCollection* fromRandom(uint32_t size);
	static MessageCollection* fromFile(char* path);
	static MessageCollection* fromRaw(Serialization s);
};

//CipherMessageCollection
class CipherMessageCollection : public ISerializable 
{
	MessageCollection* col;
public:
	CipherMessageCollection( MessageCollection* col ) : col(col) {}
	~CipherMessageCollection();
	const CipherMessage* get(const uint32_t n);
	uint32_t getSize() const;	
	const Serialization getSerialization() const;
	static CipherMessageCollection* fromRaw(Serialization s);
};

#endif
